class CityList {
  
  constructor(pageContext) {
    this.page = pageContext;
    this.page.loadCityView = this.loadCityView.bind(this)
    this.page.leftChooseCity = this.leftChooseCity.bind(this)
    this.page.centerChooseCity = this.centerChooseCity.bind(this)
    this.page.closeCityList = this.closeCityList.bind(this)
    this.page.rightChooseCity = this.rightChooseCity.bind(this)
    
  }

  closeCityList(){
    let self = this.page
    self.setData({
      isShowCityList: false,
    })
  }
  
  leftChooseCity(res) {
    let self = this.page
    var chooseIndex = res.currentTarget.dataset.chooseindex
    var leftCityName = self.data.cityList[chooseIndex].name
    var centerCity = self.data.cityList[chooseIndex].sub
    var rightCity = centerCity[1].sub
    self.setData({
      leftCityName: leftCityName,
      centerCity: centerCity,
      rightCity: rightCity
    })
  }
  centerChooseCity(res) {
    let self = this.page
    var chooseIndex = res.currentTarget.dataset.chooseindex
    var centerCity = self.data.centerCity
    var rightCity = centerCity[chooseIndex].sub
    self.setData({
      centerCity, centerCity,
      rightCity: rightCity
    })
  }

  rightChooseCity(res) {
    let self = this.page
    var chooseName = res.currentTarget.dataset.choosename
    var centerCity = self.data.centerCity
    let btnName = self.data.btnName
    if (btnName == "dep"){
      self.setData({
        depName:chooseName,
      })
    }else{
      self.setData({
        arrvieName: chooseName,
      })
    }
    self.setData({
      
      isShowCityList: false,
    })
  }
 
  loadCityView() {
   let self = this.page
   let cityList = [
      { name: "请选择", sub: [{ name: "请选择" }], type: 1 },
      {
        name: "河南",
        sub: [{ name: "请选择", sub: [] },
        {
          name: "郑州",
          sub: [{ name: "请选择" }, { name: "中原区" }, { name: "金水区" }, { name: "二七区" }, { name: "管城回族区" }, { name: "上街区" }, { name: "惠济区" }, { name: "巩义市" }, { name: "新郑市" }, { name: "新密市" }, { name: "登封市" }, { name: "荥阳市" }, { name: "中牟县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "开封",
          sub: [{ name: "请选择" }, { name: "鼓楼区" }, { name: "龙亭区" }, { name: "顺河回族区" }, { name: "禹王台区" }, { name: "金明区" }, { name: "开封县" }, { name: "尉氏县" }, { name: "兰考县" }, { name: "杞县" }, { name: "通许县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "洛阳",
          sub: [{ name: "请选择" }, { name: "西工区" }, { name: "老城区" }, { name: "涧西区" }, { name: "瀍河回族区" }, { name: "洛龙区" }, { name: "吉利区" }, { name: "偃师市" }, { name: "孟津县" }, { name: "汝阳县" }, { name: "伊川县" }, { name: "洛宁县" }, { name: "嵩县" }, { name: "宜阳县" }, { name: "新安县" }, { name: "栾川县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "平顶山",
          sub: [{ name: "请选择" }, { name: "新华区" }, { name: "卫东区" }, { name: "湛河区" }, { name: "石龙区" }, { name: "汝州市" }, { name: "舞钢市" }, { name: "宝丰县" }, { name: "叶县" }, { name: "郏县" }, { name: "鲁山县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "安阳",
          sub: [{ name: "请选择" }, { name: "北关区" }, { name: "文峰区" }, { name: "殷都区" }, { name: "龙安区" }, { name: "林州市" }, { name: "安阳县" }, { name: "滑县" }, { name: "内黄县" }, { name: "汤阴县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "鹤壁",
          sub: [{ name: "请选择" }, { name: "淇滨区" }, { name: "山城区" }, { name: "鹤山区" }, { name: "浚县" }, { name: "淇县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "新乡",
          sub: [{ name: "请选择" }, { name: "卫滨区" }, { name: "红旗区" }, { name: "凤泉区" }, { name: "牧野区" }, { name: "卫辉市" }, { name: "辉县市" }, { name: "新乡县" }, { name: "获嘉县" }, { name: "原阳县" }, { name: "长垣县" }, { name: "封丘县" }, { name: "延津县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "焦作",
          sub: [{ name: "请选择" }, { name: "解放区" }, { name: "中站区" }, { name: "马村区" }, { name: "山阳区" }, { name: "沁阳市" }, { name: "孟州市" }, { name: "修武县" }, { name: "温县" }, { name: "武陟县" }, { name: "博爱县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "濮阳",
          sub: [{ name: "请选择" }, { name: "华龙区" }, { name: "濮阳县" }, { name: "南乐县" }, { name: "台前县" }, { name: "清丰县" }, { name: "范县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "许昌",
          sub: [{ name: "请选择" }, { name: "魏都区" }, { name: "禹州市" }, { name: "长葛市" }, { name: "许昌县" }, { name: "鄢陵县" }, { name: "襄城县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "漯河",
          sub: [{ name: "请选择" }, { name: "源汇区" }, { name: "郾城区" }, { name: "召陵区" }, { name: "临颍县" }, { name: "舞阳县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "三门峡",
          sub: [{ name: "请选择" }, { name: "湖滨区" }, { name: "义马市" }, { name: "灵宝市" }, { name: "渑池县" }, { name: "卢氏县" }, { name: "陕县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "南阳",
          sub: [{ name: "请选择" }, { name: "卧龙区" }, { name: "宛城区" }, { name: "邓州市" }, { name: "桐柏县" }, { name: "方城县" }, { name: "淅川县" }, { name: "镇平县" }, { name: "唐河县" }, { name: "南召县" }, { name: "内乡县" }, { name: "新野县" }, { name: "社旗县" }, { name: "西峡县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "商丘",
          sub: [{ name: "请选择" }, { name: "梁园区" }, { name: "睢阳区" }, { name: "永城市" }, { name: "宁陵县" }, { name: "虞城县" }, { name: "民权县" }, { name: "夏邑县" }, { name: "柘城县" }, { name: "睢县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "信阳",
          sub: [{ name: "请选择" }, { name: "浉河区" }, { name: "平桥区" }, { name: "潢川县" }, { name: "淮滨县" }, { name: "息县" }, { name: "新县" }, { name: "商城县" }, { name: "固始县" }, { name: "罗山县" }, { name: "光山县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "周口",
          sub: [{ name: "请选择" }, { name: "川汇区" }, { name: "项城市" }, { name: "商水县" }, { name: "淮阳县" }, { name: "太康县" }, { name: "鹿邑县" }, { name: "西华县" }, { name: "扶沟县" }, { name: "沈丘县" }, { name: "郸城县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "驻马店",
          sub: [{ name: "请选择" }, { name: "驿城区" }, { name: "确山县" }, { name: "新蔡县" }, { name: "上蔡县" }, { name: "西平县" }, { name: "泌阳县" }, { name: "平舆县" }, { name: "汝南县" }, { name: "遂平县" }, { name: "正阳县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "焦作",
          sub: [{ name: "请选择" }, { name: "济源市" }, { name: "其他" }],
          type: 0
        },
        { name: "其他" }],
        type: 1
      },
      {
        name: "江西",
        sub: [{ name: "请选择", sub: [] },
        {
          name: "南昌",
          sub: [{ name: "请选择" }, { name: "东湖区" }, { name: "西湖区" }, { name: "青云谱区" }, { name: "湾里区" }, { name: "青山湖区" }, { name: "新建县" }, { name: "南昌县" }, { name: "进贤县" }, { name: "安义县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "景德镇",
          sub: [{ name: "请选择" }, { name: "珠山区" }, { name: "昌江区" }, { name: "乐平市" }, { name: "浮梁县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "萍乡",
          sub: [{ name: "请选择" }, { name: "安源区" }, { name: "湘东区" }, { name: "莲花县" }, { name: "上栗县" }, { name: "芦溪县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "九江",
          sub: [{ name: "请选择" }, { name: "浔阳区" }, { name: "庐山区" }, { name: "瑞昌市" }, { name: "九江县" }, { name: "星子县" }, { name: "武宁县" }, { name: "彭泽县" }, { name: "永修县" }, { name: "修水县" }, { name: "湖口县" }, { name: "德安县" }, { name: "都昌县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "新余",
          sub: [{ name: "请选择" }, { name: "渝水区" }, { name: "分宜县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "鹰潭",
          sub: [{ name: "请选择" }, { name: "月湖区" }, { name: "贵溪市" }, { name: "余江县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "赣州",
          sub: [{ name: "请选择" }, { name: "章贡区" }, { name: "瑞金市" }, { name: "南康市" }, { name: "石城县" }, { name: "安远县" }, { name: "赣县" }, { name: "宁都县" }, { name: "寻乌县" }, { name: "兴国县" }, { name: "定南县" }, { name: "上犹县" }, { name: "于都县" }, { name: "龙南县" }, { name: "崇义县" }, { name: "信丰县" }, { name: "全南县" }, { name: "大余县" }, { name: "会昌县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "吉安",
          sub: [{ name: "请选择" }, { name: "吉州区" }, { name: "青原区" }, { name: "井冈山市" }, { name: "吉安县" }, { name: "永丰县" }, { name: "永新县" }, { name: "新干县" }, { name: "泰和县" }, { name: "峡江县" }, { name: "遂川县" }, { name: "安福县" }, { name: "吉水县" }, { name: "万安县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "宜春",
          sub: [{ name: "请选择" }, { name: "袁州区" }, { name: "丰城市" }, { name: "樟树市" }, { name: "高安市" }, { name: "铜鼓县" }, { name: "靖安县" }, { name: "宜丰县" }, { name: "奉新县" }, { name: "万载县" }, { name: "上高县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "抚州",
          sub: [{ name: "请选择" }, { name: "临川区" }, { name: "南丰县" }, { name: "乐安县" }, { name: "金溪县" }, { name: "南城县" }, { name: "东乡县" }, { name: "资溪县" }, { name: "宜黄县" }, { name: "广昌县" }, { name: "黎川县" }, { name: "崇仁县" }, { name: "其他" }],
          type: 0
        },
        {
          name: "上饶",
          sub: [{ name: "请选择" }, { name: "信州区" }, { name: "德兴市" }, { name: "上饶县" }, { name: "广丰县" }, { name: "鄱阳县" }, { name: "婺源县" }, { name: "铅山县" }, { name: "余干县" }, { name: "横峰县" }, { name: "弋阳县" }, { name: "玉山县" }, { name: "万年县" }, { name: "其他" }],
          type: 0
        },
        { name: "其他" }],
        type: 1
      },
    ]

    var leftCityName = cityList[1].name
    var centerCity = cityList[1].sub
    var rightCity = centerCity[1].sub
    self.setData({
      cityList: cityList,
      leftCityName: leftCityName,
      rightCity: rightCity,
      centerCity: centerCity
    })
  }

  

  
}


module.exports = CityList;